Subject: ReadStr() Study
From: "Barry D. Wills" <[email-masked]>
To: "amigae" <[email-masked]>
Date: 24 Jul 93 20:41:00 CST

This archive contains 8 programs which compare ReadStr() algorithms:
  ReadStr-std-1.e:  E's ReadStr() behaviour reading from stdout.
  ReadStr-std-2.e:  posted readStr() behaviour reading from sdtout.
  ReadStr-std-3.e:  my readStr() behaviour reading from stdout.
  rwt1.e:  read/write ascii file, E's ReadStr().
  rwt2.e:  read/write ascii file, posted readStr().
  rwt3.e:  read/write ascii file, my readStr() without using enhancement.
  rwt4.e:  read/write ascii file, my readStr() using enhancement.
  rwt5.e:  read/write ascii file, my buffered readStr() (from EPP.)

Well, I couldn't resist the temptation.  When I saw the ReadStr() routine
posted with such a bold claim (8x faster) I had give it the acid test.  It
is indeed very fast.  But I found some surprising facts.  First, it's close
but not completely compatible with E's ReadStr().  The only real difference
is how it handled input strings that are longer than the target string.  This
is most evident in the test ReadStr-std-2.e, reading from stdout.  I saw some
redundant function calls and variable assignments, so I modified it, making
the routine faster.  I think it behaves exactly like E's ReadStr() now.  My
buffered readStr() from EPP kicked everyone's butt, which surprised the heck
out of me since I was hoping to get a faster routine from all this! :-)

What it all boils down to is:  I tested these in ram on E's Reference.doc,
about 93k, with a 68030 and a 68000.  Here are the results:

            030  ticks    000  ticks
            ----------    ----------
  rwt1.e         2934          9531  (3 1/3 minutes)
  rwt2.e          408          1869
  rwt3.e          399          1813
  rwt4.e          397          1800
  rwt5.e          159           713

Note 1:  I almost always want to get the StrLen() of a read string, so I
modified my routine to return the length of the string since it already knows
it.  -1 still means EOF.

Note 2:  I turned the buffered read string stuff into a PMODULE if anyone
(KS1.3 people!) is interested.

Note 3:  the 3 stdout tests run forever, so you might want to fix 'em if you
plan on using your cli for anything else.

Think that's about it.
-- Barry

size 9874